<?php
/*************************************************************************
Index page
----------------------------------------------------------------
Project		: PICKCOCMS
Company		: "Pick VN" 
Email		: southseapro@gmail.com                                 
Last updated: 09/12/2011
Author		: Nguyen Hai Nam
**************************************************************************/
# Set to 9 if you want to debug
error_reporting(9);
# Autodetect current root folder
if (!defined('ROOT_PATH')) {
	define('ROOT_PATH', dirname(__FILE__).'/');
}

include_once(ROOT_PATH.'configs/config.php');
include_once(ROOT_PATH.'includes/constant.php');
include_once(ROOT_PATH.'includes/autoload.php');
include_once(ROOT_PATH."includes/functions.php");

#Create database connection
$load 	= new Pick_Core_Load();
$db 	= new Pick_Core_Mysql();
$url 	= new Pick_Http_Url();
$logs   = new Pick_Core_Logs();
$logs->start();
$languages 	= new Pick_Core_Languages();

# Template configuration
$template = new Smarty;
$template->setTemplateDir(dirname(__FILE__).'/templates');
$template->setCompileDir(dirname(__FILE__).'/compile');
$template->setCacheDir(dirname(__FILE__).'/cache');
$template->force_compile 	= TEMPLATE_COMPILE;
$template->debugging 		= TEMPLATE_DEBUG;
$template->caching 			= CACHING;
$template->cache_lifetime 	= CACHE_LIFETIME;

# HTTP Request manager
$request = new Pick_Http_Request();
$op = strtolower($request->element('op')?$request->element('op'):DEFAULT_OP);

# Session manager
include_once(ROOT_PATH.'includes/session.php');

# Language manager
include_once(ROOT_PATH.'includes/lang.php');

# Operations manager
include_once(ROOT_PATH.'includes/basic.php');
include_once(ROOT_PATH.'includes/plugins.php'); 
include_once(ROOT_PATH.'includes/modules.php');

# update log
$logs->update();

# Close database connection
$db->close();
# Free memmory
unset($logs);
unset($load);
unset($db);
unset($template);
unset($request);
unset($messages);
unset($languages);